#include "stdafx.h"
#include <ObjBase.h>
#include "BusManager\BusManager.h"
#include <algorithm>
#include "base\logging.h"
#include "base\bind.h"
#include "..\..\Content\ThreadManager.h"

namespace DataManager
{
 
//////////////BusManager/////////////////////////////////
BusManager* BusManager::GetInstance()
{
	return Singleton<BusManager>::get();
}
 
BusManager::BusManager()
{	
	history_data_set_manager_.reset(new HistoryDataSetUnionManager);
	data_operation_.reset(new DataSetOperation);
	data_operation_->Init(this);
}

void BusManager::AddDataSetChangeObserver(const ChangeUnionCallback &changeUnionCallback)	
{
	DFAKE_SCOPED_LOCK(data_set_change_callback_list_lock_);
	data_set_change_callback_list_.AddObserver( changeUnionCallback );
}

void BusManager::RemoveDataSetChangeObserver(const ChangeUnionCallback &changeUnionCallback)	
{
	DFAKE_SCOPED_LOCK(data_set_change_callback_list_lock_);
	data_set_change_callback_list_.RemoveObserver( changeUnionCallback );
}
 

void BusManager::StopCollectData()
{
	data_set_union_ =  NULL;
	history_data_set_manager_.reset();
//	data_operation_->EndSaveData();
	data_operation_->StopCollectData(); 
	data_operation_.reset();
}

}